package io.xiaojl.xj2ee.modules.sys.service.impl;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

import io.xiaojl.xj2ee.common.kit.PageWrapper;
import io.xiaojl.xj2ee.kit.JpaPageKit;
import io.xiaojl.xj2ee.modules.sys.entity.SysLogEntity;
import io.xiaojl.xj2ee.modules.sys.repository.SysLogRepository;
import io.xiaojl.xj2ee.modules.sys.service.SysLogService;


@Service("sysLogService")
public class SysLogServiceImpl implements SysLogService {
	@Autowired
	private SysLogRepository sysLogRepository;
	
    @Override
    public PageWrapper<SysLogEntity> queryPage(Map<String, Object> params) {
    	PageWrapper<SysLogEntity> pw = new PageWrapper<SysLogEntity>(params);
		Pageable pageable = JpaPageKit.getPageable(pw);
		Page<SysLogEntity> page = sysLogRepository.findAll(pageable);
		pw.setList(page.getContent());
		pw.setTotalCount(Integer.parseInt(page.getTotalElements()+""));
		pw.setTotalPage(page.getTotalPages());
        return pw;
    }

	@Override
	public int insert(SysLogEntity sysLog) {
		sysLogRepository.save(sysLog);
		return 1;
	}

}
